/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.krazevina.kar;

import java.util.Vector;

/**
 *
 * @author XXX
 */
public class Artist {
    public String name,rawname;
    public Artist(){}
    public Artist(String name,String rname){
        this.name = name;
        this.rawname = rname;
    }
    
    public Artist(String line){
        String[]lines = split(line,",");
        try{
            name = lines[0].substring(1, lines[0].length()-1);
            if(lines[1].length()>0)
                rawname = lines[1].substring(1, lines[1].length()-1);
            else rawname = "";
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    private String[] split(String original,String separator) {
        Vector nodes = new Vector();
        int index = original.indexOf(separator);
        while(index>=0) {
            nodes.addElement( original.substring(0, index) );
            original = original.substring(index+separator.length());
            index = original.indexOf(separator);
        }
        nodes.addElement( original );
        String[] result = new String[ nodes.size() ];
        if( nodes.size()>0 ) {
            for(int loop=0; loop<nodes.size(); loop++)
                result[loop] = (String)nodes.elementAt(loop);
        }
        return result;
    }
    
}
